import base64


class Response:
    def __init__(self, status, message, field_errors=None, data=None):
        self.status = status
        self.message = message
        self.field_errors = field_errors
        self.data = data or []

    # 将对象转换为字典格式，以便返回 JSON 响应
    def to_dict(self):
        return {
            "status": self.status,
            "message": self.message,
            "fieldErrors": self.field_errors,
            "data": self.data
        }


def get_vector_index_name(application_name, index_name):
    return application_name + ":" + index_name


def base_64_encode(data):
    return base64.b64encode(data.encode("utf-8")).decode('utf-8')
